package exam.model.dao;

import java.util.List;

import exam.model.entity.TQuestionEntity;
public class QuestionDAO extends AbstractDao<TQuestionEntity>{
	
	public QuestionDAO() {
		super(TQuestionEntity.class);
	}
	
	public List<TQuestionEntity> selectListQuestion() {
		return super.selectList("select q from TQuestionEntity q left outer join q.subQuestionEntity");
	}
	
	public List<TQuestionEntity> select001(Long examId) {
		String query = "select q from TQuestionEntity q, TQuestionExamEntity qe" +
		" where q.questionId=qe.questionId and qe.examId="+examId;
		return super.selectList(query);
	}
	public List<TQuestionEntity> selectListQuestion(String query) {
		return super.selectList(query);
	}
	
	public TQuestionEntity selectByPk(long id) {
		return super.selectByPk(id);
	}
	
	public void insertQuestion(TQuestionEntity question) {
		super.insert(question);
	}
	
	public void updateQuestion(TQuestionEntity question) {
		super.update(question);
	}
	
	public void deleteQuestionByPk(long questionId) {
		super.delete(questionId);
	}
	
	public Object maxQuestionId() {
		String query = "select max(q.questionId) from TQuestionEntity q";
		return super.jdbcManager.executeByQuery(query).getObjectResult();
	}
}
